{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "from scipy import signal as sg\n",
    "from time import sleep\n",
    "from PIL import Image\n",
    "import numpy as np\n",
    "import string\n",
    "import shutil\n",
    "import base64\n",
    "import cv2\n",
    "import re\n",
    "import os"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "contextbox = open('1.box', mode='r', encoding='UTF8').read()\n",
    "contextboxnopunc = re.sub(r'[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\-\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\_\\`\\{\\|\\}\\~“”、，。《》°](.+)\\n', '', re.split(r'(推.+\\n荐.+\\n)|(出.+\\n题.+\\n)', contextbox)[0])\n",
    "contextnopunc = ''.join(re.split(r' .+\\n', contextboxnopunc))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('215 833 247 867', '215 833 247 867')]"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ansnopunc = '县'\n",
    "ansnopunc.replace('',' ((.+)) 0\\n')[8:]\n",
    "re.findall(ansnopunc.replace('',' ((.+)) 0\\n')[8:], contextboxnopunc)\n",
    "#re.findall(ansnopunc.replace('',' (.+) 0\\n')[8:], contextboxnopunc)[-1].split(' ')[1]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('58 432 133 466', '58 432 133 466', '111 416 135 470', '111 416 135 470')]"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ansnopunc = '安徽'\n",
    "ansnopunc.replace('',' (.+) 0\\n')[8:]\n",
    "re.findall(ansnopunc.replace('',' ((.+)) 0\\n')[8:], contextboxnopunc)\n",
    "#re.findall(ansnopunc.replace('',' (.+) 0\\n')[8:], contextboxnopunc)[-1][0].split(' ')[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "tartemp = 1200 - int(re.findall(ansnopunc.replace('',' (.+) 0\\n')[8:], contextboxnopunc)[-1][0].split(' ')[1])"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}